<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>文件上传</title>
</head>
<body>
<h1>普通springboot</h1>
<form action="/file/upload" method="POST"
      enctype="multipart/form-data">
    <input type="file" name="file"> <br>
    <input type="submit" value="submit">
</form>
<hr/>

<h1>七牛云-表单上传</h1>

<form enctype="multipart/form-data" id="qiniuUpload" action="http://upload-z2.qiniup.com/" method="POST">
    <input name="file" type="file"/>
    <input name="token" type="hidden">
    <input name="key" type="hidden">
    <input type="submit" value="上传文件"/>
</form>

</body>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

</html>
<script>

    $(function () {
        qiniuOOS.geToken();
    });

    var qiniuOOS = {
        geToken: function () {
            $.ajax({
                url: this.url.uploadToken,
                success: function (data) {
                    if (data.code == 0) {
                        $('input[name="token"]').attr("value", data.token);
                        $('input[name="key"]').attr("value", data.key);
                    } else {
                        alert(JSON.stringify(data))
                    }
                }

            });

        },
        url: {
            uploadToken: "/upload/token"
        }
    }

</script>
